<template>
  <div class="card" v-if="item" @click.stop="toDetail">
    <!-- 占位一行 -->
    <div
      class="img-box"
      :style="{ backgroundImage: `url(${item.cover})` }"
    ></div>
    <div class="right" v-if="!showImmediateRead">
      <div class="name">{{ item.title }}</div>
      <div class="tags">{{ item.author }} / {{ item.category }}</div>
      <div class="my-text des">{{ item.content }}</div>
    </div>
    <div class="right" v-else>
      <div class="name">{{ item.title }}</div>
      <div class="my-text des">{{ item.content }}</div>
      <div class="tags">
        <div>
          {{ item.author
          }}<span v-if="item.category"> / {{ item.category }}</span>
        </div>
        <div class="tags-btn" v-if="showImmediateRead">立即阅读</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["item", "showImmediateRead"],
  methods: {
    toDetail() {
      this.$router.push({
        name: "detail",
        params: {
          bookid: this.item.id,
          title:this.item.title
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.card {
  width: 100%;
  height: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .img-box {
    width: 0.85rem;
    min-width: 0.85rem;
    height: 100%;
    position: relative;
    &::after {
      position: absolute;
      left: 0;
      bottom: -0.1rem;
      content: "";
      display: block;
      width: 100%;
      height: 0.1rem;
      background-image: linear-gradient(
        to bottom,
        var(--bgc-gray),
        rgba(#fafafa, 0)
      );
      filter: blur(0.02rem);
    }
  }
  .right {
    flex-grow: 1;
    height: 100%;
    color: var(--text-gray);
    font-size: 0.14rem;
    margin-left: 0.1rem;
    .name {
      font-size: 0.18rem;
      color: var(--text-black);
      font-weight: bold;
    }
    .tags {
      margin-top: 0.05rem;
      display: flex;
      justify-content: space-between;
      .tags-btn {
        color: var(--text-black);
      }
    }
    .des {
      width: 100%;
      height: 0.46rem;
      box-sizing: border-box;
      border: 0.05rem solid var(--bgc-gray2);
      background-color: var(--bgc-gray2);
      margin-top: 0.05rem;
      line-height: 0.18rem;
      -webkit-line-clamp: 2;
    }
  }
}
</style>